/**
 *
 * Copyright 2013 by Hai Nguyen
 *
 */
package com.avj.g17.chat.client;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * IServerSocket
 *
 * @author Hai Nguyen <hain186@gmail.com>
 * @version $Id: IServerSocket Jun 9, 2013 3:03:55 PM hainn $
 */
public class IServerSocket {

    public static void main(String[] args) {
        try {
            final int port = 4321;
            InetAddress ia = InetAddress.getLocalHost();
            ServerSocket sock = new ServerSocket(port, 20, ia);
            System.out.println("[*]Waiting for clients ....");
            while (true) //	WHILE THE PROGRAM IS RUNNING
            {
                Socket s = sock.accept();// ACCEPT SOCKETS(CLIENTS) TRYING TO CONNECT
                ServerManagemer chat = new ServerManagemer(s);	// CREATE A NEW CLIENT OBJECT
                Thread t = new Thread(chat);//MAKE A NEW THREAD
                t.start();									//	START THE THREAD
            }

        } catch (Exception ex) {
            System.err.println("[*]Error: " + ex.toString());
        }
    }
}
